package com.xh.bussiness.tiku.util;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Semaphore;

/**
 * @author Pitt Cheung
 * @date 2021/7/28 17:24
 */
public class Test2 {

    public static Semaphore semaphore = new Semaphore(10);

    public static void main(String[] args) {
        String s = "-高中地理综合库-高中地理综合库-自然地理-地表形态的塑造-山地的形成-";
        String[] split = s.split("-");
        List<String> strings = Arrays.asList(split);
        Iterator<String> it = strings.iterator();

        while (it.hasNext()) {
            System.out.println(it.next());
        }

        /*for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                try {
                    if (semaphore.availablePermits() == 0) {
                        System.out.println("暂无车位");
                    }
                    semaphore.acquire();
                    System.out.println(Thread.currentThread().getName() + "成功进入停车场");
                    Thread.sleep(5000);
                    System.out.println(Thread.currentThread().getName() + "驶离停车场");
                    semaphore.release();
                } catch (Exception e) {

                }
            }, i + "号车").start();
        }*/
    }

}
